<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/


Route::prefix('v1/user')->namespace('API')->group(function () {
    Route::post('login', 'UserWechatController@login');

    // 需要微信登录获取用户身份
    Route::middleware('auth:wechat')->group(function () {
        Route::get('/', function (Request $request) {
            return $request->user();
        });

        Route::prefix('address')->group(function () {
            Route::get('/', 'AddressController@index');
            Route::get('/{address}', 'AddressController@show');
            Route::post('/', 'AddressController@store');
            Route::delete('/{address}', 'AddressController@destroy');
            Route::post('setCurrentAddress', 'AddressController@setCurrentAddress');
        });
    });
});